package com.hexu.sharedb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hexu.sharedb.entity.SchoolTerm;
import com.hexu.sharedb.mapper.SchoolTermMapper;
import com.hexu.sharedb.service.SchoolTermService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author gufusheng
 * @time 2021/7/19 16:08
 */
@Service("schoolTermService")
public class SchoolTermServiceImpl implements SchoolTermService {

    @Resource
    SchoolTermMapper schoolTermMapper;

    @Override
    public SchoolTerm getTerm(Integer tid) {
        return schoolTermMapper.selectById(tid);
    }

    @Override
    public List<SchoolTerm> getList() {
        return schoolTermMapper.selectList(new QueryWrapper<>());
    }

    @Override
    public SchoolTerm lastTerm() {
        return schoolTermMapper.selectOne(new QueryWrapper<SchoolTerm>().eq("is_last", 1));
    }
}
